package com.qf.commons.web.feign;

import com.qf.commons.web.utils.HttpUtils;
import feign.RequestInterceptor;
import feign.RequestTemplate;

import javax.servlet.http.HttpServletRequest;

/**
 * description: 请求参数的处理器
 * author: Ken
 * 公众号：Java架构栈
 */
public class RequestParamHandler implements RequestInterceptor {

    @Override
    public void apply(RequestTemplate template) {
        //获取当前请求的相关请求头
        HttpServletRequest request = HttpUtils.getRequest();
        String uid = request.getHeader("uid");
        //将当前的参数，设置给feign
        template.header("uid", uid);
    }
}
